<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../../include/admincontent.jsp" %>
<div id="location">当前位置：系统信息管理 > 学校账户管理</div>
<div id="sy_search" class=" f0f0f0" style="display: inline-block">
    <form id="advanceQueryParam">
        <div style="background-color: #f0f0f0">
            <div class="clearfix more_query_area">
                <div class="query_area_body clearfix">
                    <div class="record_item">
                        <div class="record_item">
                            <div class="label">关键词:</div>
                            <div class="content">
                                <div><input type="text" name="key"/></div>
                            </div>
                        </div>
                    </div>
                    <div class="record_item">
                        <div class="record_item">
                            <div class="label">状态:</div>
                            <div class="content">
                                <div><select name="state">
                                    <option value="-1">全部</option>
                                    <option value="0">启用</option>
                                    <option value="1">禁用</option>
                                </select></div>
                            </div>
                        </div>
                    </div>

                    <%-- <div class="query_area_footer clearfix">
                         <div class="query_btns clearfix">
                             <div class="query_btn left blue" id="searchbtn">
                                 <span class="label">查询</span>
                             </div>
                             <div class="query_btn left gray" id="searchreset">
                                 <span class="label">重置</span>
                             </div>
                         </div>
                     </div>--%>
                    <div class="record_item">
                        <div class="toolbars">
                            <a id="searchbtn" >
                                <em class="ico16 search_16"></em>
                                <span class="menu_span" title="查询">查询</span>
                            </a>
                            <a id="searchreset">
                                <em class="ico16 refresh_16"></em>
                                <span class="menu_span" title="重置">重置</span>
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <%--<a width="60" id="combineQuery" class="font_size12 common_button combinedQuery">查询</a>--%>
</div>
<div id="Content" class="bg-content">
    <div class="toolbars" style="height:30px;white-space:nowrap;width:auto;margin-left: 20px;" totalwidth="314">
<%--    <div class="clearfix common_toolbar_box">
        <div class="clearfix toolbar_l">--%>
            <a id="school_add">
                <em class="ico16 add_new"></em>
                <span class="menu_span">添加</span>
            </a>
            <a id="school_edit">
                <em class="ico16 editor_16"></em>
                <span class="menu_span">编辑</span>
            </a>
            <a id="school_del">
                <em class="ico16 enabled_16"></em>
                <span class="menu_span">禁用/启用</span>
            </a>
    </div>
<%--        </div>
    </div>--%>
<%--    <div id="searchbox">--%>
<%--        <form id="conditionform">--%>
<%--            <table class="treeTable searchform">--%>
<%--                <thead>--%>
<%--                <tr>--%>
<%--                    <td width="50">关键词:</td>--%>
<%--                    <td width="200">--%>
<%--                        <div><input type="text" name="key"/></div>--%>
<%--                    </td>--%>
<%--                    <td width="40">状态:</td>--%>
<%--                    <td width="100">--%>
<%--                        <div>--%>
<%--                            <select name="state">--%>
<%--                                <option value="-1">全部</option>--%>
<%--                                <option value="0">启用</option>--%>
<%--                                <option value="1">禁用</option>--%>
<%--                            </select>--%>
<%--                        </div>--%>
<%--                    </td>--%>
<%--                    <td width="30">--%>
<%--                        <button id="searchbtn" type="button" class="search"></button>--%>
<%--                    </td>--%>
<%--                    <td></td>--%>
<%--                </tr>--%>
<%--                </thead>--%>
<%--            </table>--%>
<%--        </form>--%>
<%--    </div>--%>
</div>

<div style="overflow:hidden;">
    <div id="div_table" style="bottom: 0px">
        <table class="layui-hide" id="table" lay-filter="rolesTable"></table>
    </div>
</div>

<script type="text/javascript">
    $(document).ready(function () {
        let reload;
        layui.use('table', () => {
            let table = layui.table;
            table.render({
                id: 'rolesTable'
                , elem: '#table'
                , height: 'full'
                , url: '/schooluser/getlistsLayuiJson' //数据接口
                , title: '用户表'
                , page: true //开启分页
                , cols: [[ //表头
                    {type: 'checkbox', fixed: 'left', width: '5%'}
                    , {type: 'numbers', title: '序号', fixed: 'left', width: '10%'}
                    , {field: 'ucode', title: '登录账号', width: '10%'}
                    , {field: 'uname', title: '学校名称', width: '20%'}
                    , {field: 'utel', title: '联系方式', width: '15%'}
                    , {field: 'lastlogintime', title: '最后登录时间', width: '20%'}
                    , {field: 'stateS', title: '状态', width: '20%', templet: (d)=>{return d.stateS?'禁用':'启用'}}
                ]]
            });
            reload = () => {
                table.reload('rolesTable');
            }
            $("#searchbtn").on('click', () => {
                table.reload('rolesTable', {
                    where: {
                        key: $("input[name='key']").val(),
                        state: $("select[name='state']").val(),
                    }, page: {
                        curr: 1
                    }
                    , done: (res, curr, count)=>{
                        tableresize(diff, false)
                    }
                })
            });
            //添加学校账号
            $('#school_add').click(function () {
                openLayer('添加账号', '/schooluser/add', '500px', '430px');
            });
            //修改学校账号
            $('#school_edit').click(function () {
                LEditInfo('修改账号', '/schooluser/edit?_x=2015', '500px', '430px', 'rolesTable');
            });
            //启用/禁用学校账号
            $('#school_del').click(function () {
                LDeleteInfo('/schooluser/DelAction', reload, null, 'rolesTable');
            });
        });
        function tableresize(diff, resizeout=true) {
            let height3 = $("#div_table").height();
            let height4 = $(".layui-table-body.layui-table-main").height();
            let height5 = $(".layui-form.layui-border-box.layui-table-view").height();


            if (resizeout) {
                $("#div_table").height(height3 - diff);
            }
            $(".layui-table-body.layui-table-main").height(height4 - diff);
            $(".layui-form.layui-border-box.layui-table-view").height(height5 - diff);
        }
        let diff;
        let origin = {};
        $("#combineQuery").on('click', (e) => {
            let style = $("#advanceQueryParam")[0].style;
            if (style.display === 'block') {
                style.display = 'none';
                diff = -origin.diff;
            } else {
                style.display = 'block';
                if (!origin.diff) {
                    origin.diff = document.documentElement.scrollHeight - document.documentElement.clientHeight;
                }
                diff = origin.diff;
            }
            tableresize(diff);
        });
        $("#searchreset").on('click', (e) => {
            document.getElementById("advanceQueryParam").reset();
            $("input[name='deptcode']").val("")
        });

    });

</script>
</body>
</html>